package valuetypes;

import exception.DBValueException;


public class BooleanValue extends DBValue {
	public static final int BOOL_SIZE = 1;	
	
	public BooleanValue() {
		super(BOOL_SIZE);
	}
		
	public BooleanValue(byte[] data, int offset) throws DBValueException{
		super(BOOL_SIZE, data, offset);
	}
	
	public BooleanValue(boolean bool) {
		super(BOOL_SIZE);
		setBool(bool);		
	}

	public boolean getBool(){
		return data[0] != 0;
	}
	
	public void setBool(boolean bool){
		if(bool){
			data[0] = 1;
		}
		else{
			data[0] = 0;
		}
	}

	@Override
	public String toString() {
		Boolean bool = getBool();
		return bool.toString();
	}
}
